package com.stg.controller;

import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.stg.bean.User;
import com.stg.service.RegiserValidateService;
import com.stg.service.UserService;

@Controller
@RequestMapping("/user")
public class UserController {
	
	@Resource
	private UserService userService;
	
	@Resource
	private RegiserValidateService regiserValidateService;
	
	@RequestMapping(value="/userTest",method=RequestMethod.GET)
	public String userTest(Model model,long id){
		
		User user = userService.UserTest(id);
		
		model.addAttribute("user", user);
		
		return "/user/userTest";
	}
	
	@RequestMapping(value="/regiser",method=RequestMethod.GET)
	public String userRegiser(){
		return "/user/regiser";
	}
	
	@RequestMapping(value="registerValidate",method=RequestMethod.GET)
	public String registerValidate(Model model,String email,String validateCode){
		String meg = regiserValidateService.processActivate(email, validateCode);
		model.addAttribute("meg", meg);
		return "/user/regiserValidate";
	}
	
	@RequestMapping(value="/userAdd",method=RequestMethod.GET)
	public String userRegiserPost(Model model,String email,String studentId){
		model.addAttribute("studentId", studentId);
		model.addAttribute("email", email);
		
		return "/user/userAdd";
	}
}
